January 06 2009 15:04:55
Navigation
Last Seen Users
pkoOnline
bikerbonesOnline
TramZ< 5 mins
MT< 5 mins
Grimloch< 5 mins
subaru2< 5 mins
ananz< 5 mins
elyn00:06:41
DjTazmania00:10:12
Ismet00:12:50

Guests Online: 0
Registered Members: 3,627
Newest Member: Gabbo
Downloads v7
Currently popular Downloads

Professional Down... 544
Extended Profile 504
FusionBoard 4 474
Photoalbum Mass U... 470
Avatar Studio 451
HighSlide Gallery... 416
Photo in Profile 400
VArcade 1.7 389
Wap Mod 360
Who Is Online Adm... 338

Latest Downloads


Profile Tabs 0
Online Users Extend ... 1
Login Redirect 9
Apache Errors Mod 3
View & Delete all Co... 0
Mod "index.php + mod... 5
Comments Management 2
FB Latest Referrers ... 8
Slideshow Lightbox P... 10
RSS and Panel 11
Downloads v6
Currently popular Downloads

Video Gallery 376
EXTboard 362
Extreme Theme Editor 343
Icon Package 2.0 291
Banner System v2.0.4 284
Tabbed welcome panel 281
Fuzed Shoutbox 276
Extended Profile ... 272
News.php 265
Header Banner System 221

Latest Downloads


Login Redirect 0
Mod "index.php + mod... 0
Base Games 1
Banner exchange system 0
Poll with comments a... 90
Media Streamer 5
v6.01.18 FULL 14
v6.01.16 - v6.01.17 44
v6.01.15 - v6.01.16 1
v6.01.17 - v6.01.18 8
Provider
PHPfusion-mods.net is hosted at:

110MB
Online Stats
Guests online: 6
Members online:
bikerbones, pko

registered members: 3627
newest member: Gabbo

user today: 17
user online: 8
Max. onlinerecord: 43
Max. per day: 5705
user yesterday: 3990
user month: 28199
Entire users: 101982

last 24h:
























v7 | Custom MySQL error messages
This guide will show you how to make custom error messages in PHP-Fusion, to let the user know what's wrong (instead of the MySQL error-codes)

This is my first How-To, so I'm not sure if I'm very clear.

This is especially handy if you NEED a certain image to display or just want a more user friendly error message.

This How-To was written based on Version 7 codes, any other version of PHP-Fusion may not work.


1: Make a backup of maincore.php, name it whatever you want. you can use this incase anything should go wrong.

2: open the original maincore.php (in notepad, i recommend notepad++ though)

3: search for line 18: if (eregi("maincore.php", $_SERVER['PHP_SELF'])) { die(); }

4: under that add $custerr="some nice error code here";
(line 19)

it should now look like this

if (eregi("maincore.php", $_SERVER['PHP_SELF'])) { die(); }
$custerr="some nice error code here";

5: go to line 106, the following code will start from there

// MySQL database functions
function dbquery($query) {
$result = @mysql_query($query);
if (!$result) {
echo mysql_error();
return false;
} else {
return $result;
}
}

function dbcount($field, $table, $conditions = "") {
$cond = ($conditions ? " WHERE ".$conditions : "");
$result = @mysql_query("SELECT Count".$field." FROM ".$table.$cond);
if (!$result) {
echo mysql_error();
return false;
} else {
$rows = mysql_result($result, 0);
return $rows;
}
}

function dbresult($query, $row) {
$result = @mysql_result($query, $row);
if (!$result) {
echo mysql_error();
return false;
} else {
return $result;
}
}

function dbrows($query) {
$result = @mysql_num_rows($query);
return $result;
}

function dbarray($query) {
$result = @mysql_fetch_assoc($query);
if (!$result) {
echo mysql_error();
return false;
} else {
return $result;
}
}

function dbarraynum($query) {
$result = @mysql_fetch_row($query);
if (!$result) {
echo mysql_error();
return false;
} else {
return $result;
}
}

function dbconnect($db_host, $db_user, $db_pass, $db_name) {
$db_connect = @mysql_connect($db_host, $db_user, $db_pass);
$db_select = @mysql_select_db($db_name);
if (!$db_connect) {
die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to establish connection to MySQL</b><br />".mysql_errno()." : ".mysql_error()."</div>");
} elseif (!$db_select) {
die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to select MySQL database</b><br />".mysql_errno()." : ".mysql_error()."</div>");
}
}

6: replace above with:

// MySQL database functions
function dbquery($query) {
$result = @mysql_query($query);
if (!$result) {
echo $custerr;
return false;
} else {
return $result;
}
}

function dbcount($field, $table, $conditions = "") {
$cond = ($conditions ? " WHERE ".$conditions : "");
$result = @mysql_query("SELECT Count".$field." FROM ".$table.$cond);
if (!$result) {
echo $custerr;
return false;
} else {
$rows = mysql_result($result, 0);
return $rows;
}
}

function dbresult($query, $row) {
$result = @mysql_result($query, $row);
if (!$result) {
echo $custerr;
return false;
} else {
return $result;
}
}

function dbrows($query) {
$result = @mysql_num_rows($query);
return $result;
}

function dbarray($query) {
$result = @mysql_fetch_assoc($query);
if (!$result) {
echo $custerr;
return false;
} else {
return $result;
}
}

function dbarraynum($query) {
$result = @mysql_fetch_row($query);
if (!$result) {
echo $custerr;
return false;
} else {
return $result;
}
}

function dbconnect($db_host, $db_user, $db_pass, $db_name) {
$db_connect = @mysql_connect($db_host, $db_user, $db_pass);
$db_select = @mysql_select_db($db_name);
if (!$db_connect) {
die("$custerr");
} elseif (!$db_select) {
die("$custerr");
}
}

7: Save file and re-upload
8: If anything went wrong, restore from the backup you made in step 1.

Hint:
you can also make multiple error message for each instance, for example:

if (eregi("maincore.php", $_SERVER['PHP_SELF'])) { die(); }
$custerr="query error";
$custerr2="dbcount function error";


// MySQL database functions
function dbquery($query) {
$result = @mysql_query($query);
if (!$result) {
echo $custerr;
return false;
} else {
return $result;
}
}

function dbcount($field, $table, $conditions = "") {
$cond = ($conditions ? " WHERE ".$conditions : "");
$result = @mysql_query("SELECT Count".$field." FROM ".$table.$cond);
if (!$result) {
echo $custerr2;
return false;
} else {
$rows = mysql_result($result, 0);
return $rows;
}
// rest of mysql functions here


etc :)

Hope you like it, it's a bit simple, but useful :)

Written by Joey van Hummel
Comments
#1elyn on December 10 2008 04:08:46
i see, this just seconded my idea that php fusion does not allow custom mysql error message, unless we mod the maincore >.>
Post Comment
Please Login to Post a Comment.
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Our Coders
Rizald 'Elyn' Maxwell
Diemux
Donate

Affiliates:
Venue

Shoutbox
You must login to post a message.

06/01/2009 13:21
Check out my Support PHP-Fusion v7 -> Mod/Infusion Request Smile

06/01/2009 10:14
@diemux - i've upload my mod.. with updates..

06/01/2009 09:57
just submit again, I will check both Smile

06/01/2009 06:21
how to update my uploaded mod here? i forgot to attached the images

06/01/2009 03:42
Mod "index.php + mod panels" doenst have a install.php as said on readme file

06/01/2009 01:00
Cheers!

05/01/2009 23:27
Bye!

05/01/2009 20:01
Helloy Bye!

05/01/2009 17:58
kkcafe : lol. yes i am

05/01/2009 17:30
owh.. elyn, are u Malaysian?

Advertiser
One-click Translation
Translate This Site

Render time: 0.22 seconds 472,463 unique visits